/**
 * 
 */
package com.sc.softmgr.business.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import com.alibaba.fastjson.JSONObject;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.sc.softmgr.business.service.GrayService;

/**
 * 
 * @content
 * 
 * @date 2017年6月19日
 * 
 * @author OprCalf
 * 
 */
@Service
public class GrayServiceImpl implements GrayService {

	@Autowired
	private RestTemplate restTemplate;

	@Override
	@HystrixCommand(fallbackMethod = "getGrayServiceFallback")
	public JSONObject getGrayService(String currenUserName, String originalServiceName) {
		return restTemplate.getForObject("http://CONSUMER-SYSGRAY1/inner/getGrayService?currenUserName=" + currenUserName
				+ "&originalServiceName=" + originalServiceName, JSONObject.class);
	}

	public JSONObject getGrayServiceFallback(String currenUserName, String originalServiceName) {
		JSONObject json = new JSONObject();
		json.put("data", "获取错误");
		return json;
	}

}
